import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import '../../pages/gmap/gmap.dart';
import '../../pages/gmap/gmapHelper.dart';

import '../../helper/cacheHelper.dart';

import '../../model/station.dart';
import '../../widgets/someCards.dart';

class StationMapPage extends StatefulWidget {
  @override
  StationMapPageState createState() => new StationMapPageState();
}

class StationMapPageState extends State<StationMapPage> {
  late List<Station> StationList;

  @override
  initState() {
    super.initState();

    getStation();
  }

  void getStation() async {
    var _list = await CacheHelper.GetStationList();

    setState(() {
      StationList = _list;
    });
  }

  Widget getStationMap(BuildContext context) {
    var layer = GMapHelper.getStationLayer(StationList, context);
    return MyMap(
      layers: layer,
      reLocation: true,
    );
  }

  Widget getBody(BuildContext context) {
    if (StationList == null)
      return Center(
          child: SpinKitCircle(
        color: Colors.blue,
      ));
    // TODO: implement build
    return Center(
        // margin: EdgeInsets.only(top: 8.0),
        child: getStationMap(context));
  }

  @override
  Widget build(BuildContext context) {
    //getStation();
    return getBody(context);
  }
}
